
// warn  info  error 
function writeLog( opt ) {
  let param = dealParam( opt )
  // 可以记录错误
  switch (param.type){
    case 'info':
      
      console.info(param)
      break;
    case 'warn':
      console.warn(param)
      break;
    case 'error':
      console.error(param)
      break;
    default:
      break;
  }
}



function  dealParam ( param ) {
  let _param = {
      type : 'info',
      msg : param + '',
      time : +new  Date,
    }
  
  if( typeof param != "object"  ) {
    _param.msg =  param + ''
  }
  else {
    Object.entries(param).forEach(v=>{
        if(typeof _param[v[0]] !== 'undefined' ) _param[v[0]] = param[v[0]]
    })
    
  }
  return _param
}


export default writeLog